home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / doc / plot05.pro < prev    next >
Text File  |  1997-07-08  |  1KB  |  60 lines

  1. ; This file defines two IDL procedures discussed in Chapter 10,
  2. ; "Plotting", of _Using IDL_.
  3.  
  4. ; Define a procedure that draws a box, using POLYFILL, whose corners
  5. ; are (X0, Y0) and (X1, Y1).
  6.  
  7. PRO BOX, X0, Y0, X1, Y1, color    
  8.  
  9. ;Call POLYFILL.
  10.  
  11. POLYFILL, [X0, X0, X1, X1], [Y0, Y1, Y1, Y0], COL = color
  12.  
  13. END
  14.  
  15. ; Define a procedure that draws a bar graph of the SAT data used
  16. ; in this chapter's examples.
  17.  
  18. PRO BARGRAPH, minval
  19.  
  20. ; Define variables.
  21.  
  22. @plot01
  23.  
  24. ; Define constants used in this procedure. Note that the number of
  25. ; colors used in the bar graph is defined by the number of colors
  26. ; available on your system.
  27.  
  28. del = 1./5.
  29. ncol=!d.n_colors/5
  30. colors = ncol*INDGEN(4)+ncol
  31.  
  32. ; Loop for each score.
  33.  
  34. FOR iscore = 0, 3 DO BEGIN
  35.  
  36.     ; The y value of annotation. Vertical separation is 20 data units.
  37.  
  38.     yannot = minval + 20 *(iscore+1)
  39.  
  40.     ; Label for each bar. 
  41.  
  42.     XYOUTS, 1984, yannot, names(iscore)
  43.  
  44.     ; Bar for annotation.
  45.  
  46.     BOX, 1984, yannot - 6, 1988, yannot - 2, colors(iscore)
  47.     
  48.     ; The x offset of vertical bar for each score.
  49.  
  50.     xoff = iscore * del - 2 * del    
  51.  
  52.     ; Draw vertical box for each year's score.
  53.  
  54.     FOR iyr=0, N_ELEMENTS(year)-1 DO $    
  55.         BOX, year(iyr) + xoff, minval, year(iyr) + xoff + del, $
  56.         allpts(iyr, iscore), colors(iscore)
  57.     ENDFOR
  58.  
  59. END
  60.